package com.yuanqi.dz.dc.service.impl;


import pnblog.PnbLogging;

import com.yuanqi.dz.dc.util.DZConfigRead;
import com.yuanqi.dz.dc.util.DateUtil;
import com.yuanqi.dz.dc.util.StringUtilDz;
import com.yuanqi.dz.dc.util.Util;
import com.yuanqitech.DzInfo.DzRequest;
import com.yuanqitech.powermop.dz.DZDataInterface;
import com.yuanqitech.powermop.dz.DZInfoArray;
import com.yuanqitech.refundAndDZInterFace.ThirdRefundAndDZService;
//https://gitee.com/ly_2100/PowerWebService.git
public class ThirdDZImpl implements DZDataInterface{
    
	public static final PnbLogging log = Util.LOG;
	
	public DZInfoArray getDZData(String mercharnum, String dzdate) {
		DZInfoArray dzInfoArray = new DZInfoArray();
		try {
			String address = DZConfigRead.getProperties("third_dz_address");
			if(StringUtilDz.isEmpty(address)){
				log.addError("第三方对账hs地址未配置");
				dzInfoArray = new DZInfoArray();
				dzInfoArray.setRc("-1");
				dzInfoArray.setErrormsg("第三方对账hs地址未配置");
				return dzInfoArray;
			}
			log.addTrace("调用第三方对账hs地址:"+address);
			ThirdRefundAndDZService service = (ThirdRefundAndDZService) pnbclient.util.HSClient.create(ThirdRefundAndDZService.class,address);
			
			String startdate = DateUtil.getDateTimeInterval(dzdate,"yyyyMMdd","yyyy-MM-dd");
			String enddate = DateUtil.getDateAfter(DateUtil.stringToDate(startdate, "yyyy-MM-dd"), "1");
			
			DzRequest req = new DzRequest();
			req.setStartTime(startdate);
			req.setEndTime(enddate);
			req.setMerchantNum(mercharnum);
			
			dzInfoArray =	service.ThirdDz(req);
			
		} catch (Exception e) {
			log.addError(e);
			dzInfoArray = new DZInfoArray();
			dzInfoArray.setRc("-1");
			dzInfoArray.setErrormsg("获取三方对账异常");
			return dzInfoArray;
		}
		
		return dzInfoArray;
	}
	
	public static void main(String[] args) throws Exception {
	String s=	DateUtil.getDateTimeInterval("20170221","yyyyMMdd","yyyy-MM-dd");
	String ss=  DateUtil.getDateAfter(DateUtil.stringToDate(s, "yyyy-MM-dd"),"1");
	System.out.println(s);
	System.out.println(ss);
	}
             
}
